namespace JHT.EFMigrationTest.ClassLibrary1.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddTeacher : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.TeacherInfo",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        TeacherName = c.String(nullable: false, maxLength: 50, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ClassTeacher",
                c => new
                    {
                        ClassInfoId = c.Long(nullable: false),
                        TeacherId = c.Long(nullable: false),
                    })
                .PrimaryKey(t => new { t.ClassInfoId, t.TeacherId })
                .ForeignKey("dbo.TeacherInfo", t => t.ClassInfoId, cascadeDelete: true)
                .ForeignKey("dbo.ClassInfo", t => t.TeacherId, cascadeDelete: true)
                .Index(t => t.ClassInfoId)
                .Index(t => t.TeacherId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.ClassTeacher", "TeacherId", "dbo.ClassInfo");
            DropForeignKey("dbo.ClassTeacher", "ClassInfoId", "dbo.TeacherInfo");
            DropIndex("dbo.ClassTeacher", new[] { "TeacherId" });
            DropIndex("dbo.ClassTeacher", new[] { "ClassInfoId" });
            DropTable("dbo.ClassTeacher");
            DropTable("dbo.TeacherInfo");
        }
    }
}
